<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>已确认订单</title>
<style type="text/css">
.search th{border:1px solid #ccc;background:#E6EFF6;font-weight:normal;}
.search td{border:1px solid #ccc;}
</style>
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/lan.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>
<script language="javascript" type="text/javascript">
$(function() {
$('th[type="order"]').click(function() {
var order = $(this).attr('field') + '-' + $(this).attr('order');
$('#order').val(order);
$('input[name="search"]').click();
}).css({'cursor': 'pointer', 'color': '#36c'});
var order = $('#order').val().split('-');
var field = $('th[type="order"][field="' + order[0] + '"]');
if (order[1] == 'ASC') {
field.attr('order', 'DESC').text(field.text() + '↑');
} else {
field.attr('order', 'ASC').text(field.text() + '↓');
}
if (order[0] != 'arrival_date') {
$('th[type="order"][field="arrival_date"]').attr('order', 'DESC');
}
/*$('[type="ajax_edit"]').dblclick(function() {
var value = $(this).text().replace('<br>', '');
$(this).text('');
var textarea = $('<textarea style="width:250px; height:50px;">' + value + '</textarea>');
$(this).append(textarea);
textarea.focus();
textarea.select();
var id = $(this).attr('id');
var field = $(this).attr('field');
textarea.blur(function() {
if ($.trim($(this).val()) == '') {
$(this).parent().html('');
return;
}
var _self = $(this);
$.post('index.php?app=order&act=ajax_edit&id=' + id, {'field' : field, 'value' : $(this).val()}, function(json) {
if (!json.done) {
alert(json.msg);
} else {
_self.parent().html(nl2br(_self.val()));
}
}, 'json');
});
});
});*/
var isdblclick=0;
$('[type="ajax_edit"]').dblclick(function() {
if(isdblclick==0)
{
var value = $(this).html();
}
else if(isdblclick==1)
{
var value = $(this).text();
}
isdblclick=1;
//$(this).unbind('dblclick');
//var value = $(this).html();
//alert(value);
$(this).html('');
var textarea = $('<textarea style="width:300px; height:80px;" ondblclick="return false;" >' + value + '</textarea>');

//textarea.select();
var id = $(this).attr('id');
var field = $(this).attr('field');
textarea.blur(function() {

var _self = $(this);
$.post('index.php?app=order&act=ajax_edit&id=' + id, {'field' : field, 'value' : $(this).val()}, function(json) {
if (!json.done) {
alert(json.msg);
} else {
isdblclick=0;
_self.parent().html(nl2br(_self.val()));
//_self.parent().bind('dblclick');
}
}, 'json');
});
$(this).append(textarea);
textarea.focus();
});
});
function init_order(order_id) {
$.get('index.php?app=order&act=init_order&id=' + order_id, function(json) {
location.href = location.href;
}, 'json');
}
function nl2br (str) {
var arr = str.split('\n');
var ret = '';
for (var i = 0; i < arr.length; i++) {
ret += arr[i];
if (i != arr.length - 1) {
ret += '<br>\n';
}
}
return ret;
}
</script>
<script type="text/javascript">
$(function(){
	var user_role="{$user.role}";
	if(user_role=="{$user_manager}" || user_role=="{$user_merch}" || user_role=="{$user_merch_admin}" || user_role=="{$user_factory}"){
		$('.process_views').hide();
		$('.hide_process').show();
		$('.qc_process').hide();
		$('.pp_css').css({'width':'25%'});
		$('.da_css').css({'width':'9%'});
		$('.c_css').css({'width':'5%'});
	}else if(user_role=="{$user_qc}" || user_role=="{$user_outgoing}"){
		$('.process_views').hide();
		$('.hide_process').hide();
		$('.qc_process').show();
		$('.qc_css').show();
		$('.qp_css').css({'width':'40%'});
	}else{
		$('.hide_process').hide();
		$('.qc_process').hide();
	}
	$('#order_list_view').click(function(){
		$('.hide_process').hide();
		$('.process_views').show();
		$('.qc_process').hide();
	});
	$('#process_list_view').click(function(){
		$('.process_views').hide();
		$('.hide_process').show();
		$('.qc_process').hide();
		$('.pp_css').css({'width':'25%'});
		$('.da_css').css({'width':'9%'});
		$('.c_css').css({'width':'5%'});
	});
	$('#qc_process_view').click(function(){
		$('.process_views').hide();
		$('.hide_process').hide();
		$('.qc_process').show();
		if(user_role=="{$user_qc}" || user_role=="{$user_outgoing}"){
			$('.qc_css').show();
			$('.qp_css').css({'width':'40%'});
		}else{
			$('.qp_css').css({'width':'50%'});
		}
	});
	
	//标注qc进度
	$('a.process_tips').click(function(){
		if(confirm('您确定要标注或改注此QC进度吗?')){
			var _th=$(this);
			var pid=$(this).attr('pid');
			$.ajax({
				url:'index.php?app=order&act=process_tips&pid='+pid,
				type:'get',
				dataType:'json',
				error:function(){
					alert('网络连接错误，请稍后再试');
				},
				success:function(data){
					if(data.flag){
						alert(data.msg);
						if(data.tips){
							_th.parent().parent().addClass('process_color');
						}else{
							_th.parent().parent().removeClass('process_color');
						}
					}else{
						alert(data.msg);
					}
				}
			});
		}else{
			return false;
		}
	});
});
</script>
<link href="template/style/css/style.css" type="text/css" rel="stylesheet" />
<style type="text/css">
.process_color{
	color:red
}
</style>
</head>
<body>
<div class="sub-body">
	<div id="head">
		<div  id="search">
			<form action="index.php" method="get">
					<table width="80%" cellspacing="0" cellpadding="0" class="search">
						<tr>
							<th width="100">{$lang.order_sn}：</th>
							<td width="200"><input type="text" id="order_sn" name="order_sn" class="input-1" value="{$smarty.get.order_sn}" /></td>
							<th width="100">{$lang.style_sn}：</th>
							<td width="200"><input type="text" id="style_sn" name="style_sn" class="input-1" value="{$smarty.get.style_sn}" /></td>
                            <th width="100">{$lang.brand_name}：</th>
							<td width="200"><select name="brand_id" id="brand_id" onChange="brand_change(this.value);" {if $user.role eq USER_FACTORY}disabled="disabled"{/if}>
									<option value="0"></option>
									<!--{foreach from=$brand_list item=brand key=k}-->
									<option value="{$brand.brand_id}"{if $smarty.get.brand_id == $brand.brand_id} selected{/if}>{$brand.brand_name}&nbsp;&nbsp;({$brand.company_name|escape})</option>
									<!--{/foreach}-->
								</select></td>
							<td width="100" {if $is_into}rowspan="3"{else}rowspan="2"{/if}><input type="hidden" name="app" value="order" />
								<input type="hidden" name="act" value="shipment" />
								<input type="hidden" name="order" id="order" value="{if $smarty.get.order}{$smarty.get.order}{else}order_create_date-DESC{/if}" />
								<input type="submit" name="search" value="{$lang.search}" class="inquiry" /></td>
                                	
						</tr>
						<tr>
						
							<th>{$lang.buyer_name}：</th>
							<td><select name="buyer_id" id="buyer_id"{if $role != USER_MERCHANDISER && $role!=USER_CLIENT} onChange="buyer_change(this.value);"{/if} {if $user.role eq USER_FACTORY}disabled="disabled"{/if}>
									<option value="0"></option>
									<!--{foreach from=$buyer_list item=buyer}-->
									<option value="{$buyer.user_id}"{if $smarty.get.buyer_id == $buyer.user_id} selected{/if}>{$buyer.user_name}</option>
									<!--{/foreach}-->
								</select></td>
							<th>{$lang.merchandiser}：</th>
							<td><select name="merchandiser_id" id="merchandiser_id">
									<option value="0"></option>
									<!--{foreach from=$merchandiser_list item=merchandiser}-->
									<option value="{$merchandiser.user_id}"{if $smarty.get.merchandiser_id == $merchandiser.user_id} selected{/if}>{$merchandiser.user_name}</option>
									<!--{/foreach}-->
								</select></td>
								<!-- {if $user.role!=USER_CLIENT} -->
                               	<th class="right">工&nbsp;&nbsp;&nbsp;&nbsp;厂：</th>
								<td><select name="factory_id" id="factory_id">
	                            {if $user.role eq USER_FACTORY}
	                            <option value="{$user.factory_id}">{$user.factory_name}</option>
	                            {else}
								<option value="0"></option>
								<!--{foreach from=$factory_list item=factory}-->
								<option value="{$factory.factory_id}"{if $smarty.get.factory_id == $factory.factory_id} selected{/if}>{$factory.factory_name}</option>
								<!--{/foreach}-->
                                {/if}
								</select></td>
								<!-- {else} -->
								<th>&nbsp;</th>
								<td>&nbsp;</td>
								<!-- {/if} -->
						</tr>
						<!-- {if $is_into} -->
						<tr>
							<th>质&nbsp;&nbsp;&nbsp;&nbsp;检：</th>
							<td>
								<select name="qc_id" id="qc_id">
									<option value=""></option>
									<!--{foreach from=$qc_list item=qcs}-->
									<option value="{$qcs.user_id}"{if $smarty.get.qc_id == $qcs.user_id} selected{/if}>{$qcs.user_name}</option>
									<!--{/foreach}-->
								</select>
							</td>
							<td colspan="4">&nbsp;</td>
						</tr>
						<!-- {/if} -->
					</table>
				</form>
			<script>
<!--{if $role==USER_MERCHANDISER}-->
$('#merchandiser_id option:first-child').remove();
$('#merchandiser_id').val('{$user.user_id}');
$('#merchandiser_id').attr('readonly','readonly');
<!--{/if}-->
<!--{if $role==USER_CLIENT}-->
$('#buyer_id option:first-child').remove();
$('#buyer_id').val('{$user.user_id}');
$('#buyer_id').attr('readonly','readonly');
<!--{/if}-->
</script> 
		</div>
	</div>
	<div class="Create" style="margin-top: 10px;">  </div>
	<div class="tab_info" id="order_list">
		<div class="tab-title-1">
			<span id="order_list_view" style="cursor: pointer;">{$lang.order_list}</span>&nbsp;&nbsp;
			<!-- {if $user.role!=USER_CLIENT} -->
			<span id="process_list_view" style="cursor: pointer;">进度视图</span>&nbsp;&nbsp;
			<span id="qc_process_view" style="cursor: pointer;">QC进度</span>
			<!-- {/if} -->
		</div>
		<table width="100%" cellspacing="0" cellpadding="0" class="tab-display" id="tab-color1">
			<tr>
				<th width="3%">{$lang.No}</th>
				<th width="7%" class="process_views" type="order" field="order_create_date" order="ASC">{$lang.order_create_date}</th>
				<th width="4%" class="process_views" type="order" field="brand_name" order="ASC">{$lang.brand_name}</th>
				<th width="6%" class="process_views" type="order" field="buyer_name" order="ASC">{$lang.buyer_name}</th>
				<th width="6%" class="process_views" type="order" field="merchandiser" order="ASC">{$lang.merchandiser}</th>
				<th width="6%" type="order" field="order_sn" order="ASC">{$lang.order_sn}</th>
				<th width="6%" type="order" field="style_sn" order="ASC">{$lang.style_sn}</th>
				<th width="7%">{$lang.images}</th>
				<!-- {if $user.role==USER_CLIENT} -->
				<th width="10%" type="order" field="buyer_arrival_date" order="ASC">{$lang.buyer_arrival_date}</th>
				<!-- {else} -->
				<th width="5%" type="order" field="factory_name" order="ASC">工厂</th>
				<th width="7%" type="order" field="release_date" order="ASC">工厂入仓日期</th>
				<!-- {if $user.role==USER_MERCHANDISER || $user.role eq USER_MANAGER || $user.role==USER_MERCHANDISER_ADMIN} -->
				<th width="7%" type="order" field="buyer_arrival_date" order="ASC">客户入仓日期</th>
				<!-- {/if} -->
                <th width="6%" class="hide_process pp_css">生产板</th>
                <th width="9%" class="hide_process da_css qc_css">大货布及辅料</th>
                <th width="6%" class="hide_process c_css">船头板</th>
                <th width="6%" class="qc_process qp_css">QC进度列表</th>
                <th width="5%" class="process_views" type="order" field="is_upload_tm" order="ASC">条码</th>
               <!-- {/if} -->
               <th width="5%" class="process_views">{$lang.packedit}</th>
               <!-- {if $user.role!=USER_CLIENT} -->
               <th width="5%">小单备注</th>
               <th width="3%">制单</th>
               <!-- {/if} -->
			</tr>
			<!--{foreach from=$orders item=order key=k name=o}-->
			<tr style="height: 80px">
				<td>{$smarty.foreach.o.iteration}</td>
				<td class="process_views">{$order.order_create_date|date}</td>
				<td class="process_views">{$order.brand_name}</td>
				<td class="process_views">{$order.buyer_name}</td>
				<td class="process_views">{$order.merchandiser}</td>
				<td>
                {if $user.role eq USER_MERCHANDISER ||  $user.role eq USER_MANAGER || $user.role eq USER_QC || $user.role eq USER_OUTGOING}
                 <a href="{url app=order&act=edit&id=$order.order_id}" style="color:blue">{$order.order_sn|default:-}</a>
                {elseif $user.role eq USER_CLIENT}
                 <a href="{url app=order&act=consumer_edit&id=$order.order_id&handle=view}" style="color:blue">{$order.order_sn|default:-}</a>
                {else}
               <a href="{url app=order&act=view&id=$order.order_id}" style="color:blue">{$order.order_sn|default:-}</a>
                {/if}
                </td>
				<td>{$order.style_sn}</td>
				<td><a href="{$site_url}/{$order.front_pic}" target="_blank"><img src="{$order.front_pic}" width="80" style="border:none;" alt="图片"/></a></td>
				<!-- {if $user.role==USER_CLIENT} -->
				<td>{$order.buyer_arrival_date|date}</td>
				<!-- {else} -->
				<td>{$order.factory_name}</td>
				<td>{$order.release_date|date}</td>
				<!-- {if $user.role==USER_MERCHANDISER || $user.role eq USER_MANAGER || $user.role==USER_MERCHANDISER_ADMIN} -->
				<td>{$order.buyer_arrival_date|date}</td>
				<!-- {/if} -->
                <td class="hide_process pp_css" align="left">{$order.production_board|nl2br}</td>
                <td class="hide_process da_css qc_css" align="left">{$order.large_cargo_cloth|nl2br}</td>
                <td class="hide_process c_css" align="left">{$order.bow_board|nl2br}</td>
                <td class="qc_process qp_css" valign="top">
                	<table width="100%" cellspacing="0" cellpadding="0">
                		<tr>
                			<th width="20%">查货日期</th>
                			<th width="50%">查货进度</th>
                			<th width="10%">查货人</th>
                			<th width="20%">附件</th>
                		</tr>
                		<!-- {foreach from=$order.process_list item=process} -->
                		<tr {if $process.process_status}class="process_color"{/if}>
                			<td align="center">{$process.receipt_time|date}</td>
                			<td>{$process.process_content|escape}</td>
                			<td align="center">{$process.qc_name|escape}</td>
                			<td align="center"><a href="{url app=order&act=process_upload&pid=$process.process_id}" target="_blank">查看</a><!-- {if $user.role==USER_OUTGOING || $user.role==USER_MANAGER || $user.role eq USER_MERCHANDISER} -->|<a href="javascript:void()" class="process_tips" pid="{$process.process_id}">标注</a><!-- {/if} --></td>
                		</tr>
                		<!-- {/foreach} -->
                	</table>
                </td>
                <td class="process_views">{if $order.is_upload_tm eq 1}ok{else}&nbsp;{/if}</td>
                 <!-- {/if} -->
                 <td class="process_views">
                 {if $user.role eq USER_FACTORY}
                <a href="{url app=order&act=packedit&order_id=$order.order_id}">编辑</a>
                {elseif ($user.role eq USER_CHUANWU OR $user.role eq USER_MANAGER OR $user.role eq USER_MERCHANDISER) AND $order.pack_status neq ORDER_PACK_STATUS_NO}
                <a href="{url app=order&act=packedit&order_id=$order.order_id}">查看</a>
                {/if}
                </td>
                <!-- {if $user.role!=USER_CLIENT} -->
                <td>{$order.small_order|escape}</td>
               	<td width="5%"><!-- {if $order.ss_status==SS_STATUS_SUCCESS} --><a href="index.php?app=ss&ss_id={$order.ss_id}" target="_blank">查看</a><!-- {/if} --></td>
               	<!-- {/if} -->
			</tr>
			<!--{/foreach}-->
		</table>
		<div class="page"> {include file=page.html}</div>
	</div>
	<script language="JavaScript">
function create_order(){
location.href='index.php?app=order&act=add';
return;
$('#head').hide();
$('#order_list').hide();
$('#order_info').hide().load('{$siteurl}/index.php?app=order&act=add','',function(){
$.get('{$siteurl}/index.php?app=order&act=add',function(data){
$('#order_info').html(data);
});
$('#order_info').fadeIn('slow');});
}

</script>
	<div id="order_info"> </div>
</div>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
</html>
